/**
 * Created by IntelliJ IDEA.
 * User: christopher_moore
 * Date: Jul 24, 2007
 * Time: 2:26:37 PM
 * To change this template use File | Settings | File Templates.
 */
public class ItemKey {
    private int itemId;
    private int suffixId;
    private int enchantId;

    public ItemKey(int itemId, int suffixId, int enchantId) {
        this.itemId = itemId;
        this.suffixId = suffixId;
        this.enchantId = enchantId;
    }

    public ItemKey(String itemKeyString) {
        String itemIdPart;
        String suffixIdPart;
        String enchantIdPart;
        int delim1;
        int delim2;

        delim1 = itemKeyString.indexOf(':');
        delim2 = itemKeyString.lastIndexOf(':');

        itemIdPart = itemKeyString.substring(0, delim1);
        suffixIdPart = itemKeyString.substring(delim1 + 1,  delim2);
        enchantIdPart = itemKeyString.substring(delim2 + 1);

        try {
            this.itemId = Integer.parseInt(itemIdPart);
            this.suffixId = Integer.parseInt(suffixIdPart);
            this.enchantId = Integer.parseInt(enchantIdPart);
        } catch (NumberFormatException e) {
            System.out.println("NumberFormatException:  itemKeyString is " + itemKeyString);
            System.out.println("  itemIDPart is " + itemIdPart);
            System.out.println("  suffixIdPart is " + suffixIdPart);
            System.out.println("  enchantIdPart is " + enchantIdPart);
        }
    }

    public int getItemId() {
        return itemId;
    }

    public int getSuffixId() {
        return suffixId;
    }

    public int getEnchantId() {
        return enchantId;
    }

    public String toString() {
        return itemId + ":" + suffixId + ":" + enchantId;
    }
}
